
var PurchaseColor = {};
var PurchaseUrl = {};
var PurChaseAlert = {};
var PurchaseSize = {};
var PurchaseCount = {};

PurchaseCount.count = 100;

var purOrSaleOrderPageSize = 10;

/**
 * 跳转到新增订单
 * @type 
 */
var PUR_TO_ADD_NEW_URL = RES_PATH + "/purchase/toInput.do";

/**
 * readOnly文本框颜色
 * @type String
 */
PurchaseColor.READ_ONLY_COLOR = 'background : #ddd';

PurchaseSize.FONT_SIZE = 'font-size : 13px';

PurChaseAlert.PROMOTE_OK = '提示信息';

PurChaseAlert.PROMOTE_ERROR = '错误信息';

		var PUR_OPTION_RECORD_ID = 'pur_option_record_id_';

		// 填充图片的本地引用
		Ext.BLANK_IMAGE_URL = RES_PATH + '/htdocs/extjs/images/default/s.gif';

		var PUR_BUTTON_FDSET_ID = 'purButnFdset';
		var PUR_DEL_RECORD_ID = '_addPurchase_del_record_';
		var QUO_BUY_REOCRD_ID = '_addPurchase_buy_record_';

		var PUR_UPDATE_STRING = '_updatePur_';
		var PUR_DEL_STRING = '_delPur_';

var PUR_DETAILS_QUERY_URL = RES_PATH + "/purchase/getPurchaseOrderDetailsByOrderId.do";
var PUR_QUERY_BY_ID_URL = RES_PATH + "/purchase/getPurchaseById.do";
var PUR_INITIAL_BUTNS_URL = RES_PATH + "/purchase/showDetailsBtns.do";
var PUR_NEW_CREATE_URL = RES_PATH + "/purchase/toInput.do";
var PUR_QUERY_BY_COMPLEX = RES_PATH + "/purchase/getPurchaseListByComplex.do";
var INIT_BUTS_URL = RES_PATH + "/purchase/turnToOrderModel.do";
var PUR_QUERY_BY_CODE_URL = RES_PATH + "/purchase/getPurInfoByComplex.do";
var PUR_DEL_BY_ID_URL = RES_PATH + "/purchase/deletePur.do";
var SHOW_DETAIL_MODE_URL = RES_PATH + "/purchase/toShowDetails.do";


var PUR_DETAILS_QUERY_URL = RES_PATH + "/purchase/getPurDetailsInfoByComplex.do";
var SHOW_PUR_MODE_URL = RES_PATH + "/purchase/toShowPur.do";
var SHOW_DETAILS_GRID_ID = 'show_details_grid_id';

/**
 * 报价查询
 */
//var QUOTA_QUREY_URL = RES_PATH + "/quotation/getQuotationsByComplex.do";

/**
 * 加载主表数据
 */
var PUR_QUERY_BY_ID_URL = RES_PATH + "/purchase/getPurchaseById.do";

/**
 * 加载细表数据
 */
var PUR_QUERY_URL = RES_PATH + "/purchase/getPurchaseOrderDetailsByOrderId.do";

/**
 * 加载按钮
 */
var PUR_LOAD_BUTNS_URL = RES_PATH + "/purchase/loadBtns.do";

/**
 * 显示查询数据
 */
var PUR_TO_SHOW_URL = RES_PATH + "/purchase/toShow.do";

/**
 * 新建订单
 */
var PUR_TO_CREATE_URL = RES_PATH + "/purchase/toCreate.do";

/**
 * 查找业务伙伴
 * @type 
 */
//PurchaseUrl.PUR_FIND_PARTNER_BY_CODE_URL = RES_PATH + "/partner/query_partner!queryPartner.do";

PurchaseUrl.PUR_FIND_PART_BY_CODE_URL = RES_PATH + "/part/queryPart!getPartByCodeImplicitExt.do";

PurchaseUrl.PUR_FIND_PART_BY_CODE_AND_SOURCE = RES_PATH + "/part/queryPart!getPartByCodeAndSource.do";



var LOAD_SALE_FORM_URL = RES_PATH + '/saleOrder/loadForm.do';

var SALE_DEL_RECORD_ID = '_addSaleOrder_del_id_';

var LOAD_SALE_ORDER_DETAILS_URL = RES_PATH + '/saleOrder/loadGrid.do';

var SALE_LOAD_BUTNS_URL = RES_PATH + '/saleOrder/loadBtns.do';

var SALE_BUTTON_FDSET_ID = 'saleButnFdset';

var PURCHASE_BUTTON_FDSET_ID = 'purchaseButnFdset';


var SALE_OPEN_STRING = 'sale_open_';



var INVENTORY_SALE_REOCRD_ID = 'inventory_sale_record_id_';

var INVENTORY_QUREY_URL = RES_PATH + '/inventory/showInventoryToSale.do';

/**
 * 点击按钮操作前的确认询问
 */
function beforeClickBtnAlert(fn) {
	Ext.Msg.confirm("提示", '您确定' + this.text + '吗?', function(btnId) {
		if(btnId == 'no') {
			return false;
		} else {
			fn.createDelegate(this)();
			return true;
		}
	}.createDelegate(this));
}
		

/**
 * 批量操作前的检查
 * @return {Boolean}
 */
//function batchValidateAlert(item_store, partner_combox) {
//	var value = partner_combox.getValue();
//	if( !value ) {
//		Ext.Msg.alert(PurChaseAlert.PROMOTE_ERROR, '对不起,您还没有选择供货单位..');
//		return false;
//	}
//	if( isRecordNULL(item_store) ) {
//		Ext.Msg.alert(PurChaseAlert.PROMOTE_ERROR, '对不起,您的行记录不能为空...');
//		return false;
//	}
//	return true;
//}


/**
 * 设置省市区初始值
 */
function loadProvCityDistComb(areaId, prov_cmb, city_cmb, dist_cmb) {
	if(!areaId || areaId.trim() == '') {
		return;
	}
	
	var PROVCITYDIST_INIT_LOAD_URL = RES_PATH + "/area/getDefaultValue.do";
	
	city_cmb.getStore().removeAll();
	dist_cmb.getStore().removeAll();
	
	var tep = {};
	tep.prov_cmb = prov_cmb;
	tep.city_cmb = city_cmb;
	tep.dist_cmb = dist_cmb;
		
	Ext.Ajax.request( {
		url : PROVCITYDIST_INIT_LOAD_URL,
		params : {areaId : areaId},
		method : 'post',
		success : function(data) {
			setAreaDefaultValue(this.prov_cmb, this.city_cmb, this.dist_cmb, data);
		}.bind(tep)
	});
}

/**
 * 得到来源的显示值
 */
function getSourceName(value) {
	var rowIndex = this.source_cmb.store.find("varIndex", "" + value);
	if (rowIndex < 0)
		return PLEASE_SELECT;
	var record = this.source_cmb.store.getAt(rowIndex);
	return record ? record.get('varName') : PLEASE_SELECT;
}
